package com.iakuil.app.common.core.jsr303.constraints;


import com.iakuil.app.common.core.enums.PasswordStrategy;
import com.iakuil.app.common.core.jsr303.validators.PassWordValidator;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.*;

/**
 * 密码校验注解
 *
 * @author zenglei
 * @date 2020-11-27
 */
@Constraint(validatedBy = PassWordValidator.class)
@Repeatable(Password.List.class)
@Target({ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Password {
    /**
     * 自定义密码校验策略
     *
     * @return 密码校验策略
     */
    PasswordStrategy strategy() default PasswordStrategy.DEFAULT;

    /**
     * 自定义提示语
     *
     * @return String
     */
    String message() default "密码格式不正确，{value}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    @Target({ElementType.PARAMETER})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @interface List {
        Password[] value();
    }

}
